package com.abel.roommanager.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import com.abel.roommanager.pojo.Clazz;

public interface ClazzMapper {
    @Select("select * from class c limit #{index},#{count}")
    @Results({
    	@Result(id=true,column="id",property="id"),
    	@Result(column="cname",property="cname"),
    	@Result(column="classestime",property="classestime"),
    	@Result(column="tid",property="teacher",one=@One(
    			select="com.abel.roommanager.mapper.TeacherMapper.findTeacherByTid"
    			
   ))
    })
	List<Clazz> findAllClasses(@Param("index")int index,@Param("count")int count);
    @Select("select count(*) from class")
	int findTotalClasses();
    @Insert("insert into class(cname,tid,classestime)values(#{cname},#{tid},#{time})")
	int addClass(@Param("cname")String cname, @Param("time")String time, @Param("tid")int tid);
    @Delete("delete from class where id=#{cid}")
	int delClassByCid(int cid);
    @Select("select * from class where id=#{id}")
   Clazz findClazzByCid(int id);
    @Select("select * from class")
	List<Clazz> findClasses();
}
